# Maintainer: Lars Kanis <lars@greiz-reinsdorf.de>

_realname=libvips
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=8.13.3
pkgrel=4
pkgdesc="A fast image processing library with low memory needs (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://libvips.org/"
license=('spdx:LGPL-2.1-or-later')
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "${MINGW_PACKAGE_PREFIX}-omp"
             "${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-libheif"
             "${MINGW_PACKAGE_PREFIX}-libjxl"
             "${MINGW_PACKAGE_PREFIX}-imagemagick"
             "${MINGW_PACKAGE_PREFIX}-openslide"
             "${MINGW_PACKAGE_PREFIX}-poppler")
optdepends=("${MINGW_PACKAGE_PREFIX}-libheif: for heif module"
             "${MINGW_PACKAGE_PREFIX}-libjxl: for jxl module"
             "${MINGW_PACKAGE_PREFIX}-imagemagick: for magick module"
             "${MINGW_PACKAGE_PREFIX}-openslide: for openslide module"
             "${MINGW_PACKAGE_PREFIX}-poppler: for poppler module")
depends=("${MINGW_PACKAGE_PREFIX}-cairo"
         "${MINGW_PACKAGE_PREFIX}-cfitsio"
         "${MINGW_PACKAGE_PREFIX}-expat"
         "${MINGW_PACKAGE_PREFIX}-fftw"
         "${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-gobject-introspection-runtime"
         "${MINGW_PACKAGE_PREFIX}-lcms2"
         "${MINGW_PACKAGE_PREFIX}-libexif"
         "${MINGW_PACKAGE_PREFIX}-libgsf"
         "${MINGW_PACKAGE_PREFIX}-libimagequant"
         "${MINGW_PACKAGE_PREFIX}-libpng"
         "${MINGW_PACKAGE_PREFIX}-librsvg"
         "${MINGW_PACKAGE_PREFIX}-libtiff"
         "${MINGW_PACKAGE_PREFIX}-libwebp"
         "${MINGW_PACKAGE_PREFIX}-matio"
         "${MINGW_PACKAGE_PREFIX}-openexr"
         "${MINGW_PACKAGE_PREFIX}-openjpeg2"
         "${MINGW_PACKAGE_PREFIX}-orc"
         "${MINGW_PACKAGE_PREFIX}-pango")
source=("https://github.com/libvips/libvips/releases/download/v${pkgver}/vips-${pkgver}.tar.gz")
sha256sums=('4eff5cdc8dbe1a05a926290a99014e20ba386f5dcca38d9774bef61413435d4c')


prepare() {
  cd "${srcdir}"/vips-${pkgver}

  autoreconf -if
}

build() {
  [[ -d "${srcdir}/build-${MSYSTEM}" ]] && rm -rf "${srcdir}/build-${MSYSTEM}"
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  ../vips-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-shared \
    --disable-static \
    --disable-deprecated

  make
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  make DESTDIR="${pkgdir}" install
}
